﻿using System;
using System.Reflection;
using Csla.Core;

namespace lite.sqlserver
{
    public class CSLAPropertyBridge : IDataBridge
    {
        private IPropertyInfo field;

        public CSLAPropertyBridge(IPropertyInfo field)
        {
            this.field = field;
        }

        public bool Readable
        {
            get { return true; }
        }

        public bool Writeable
        {
            get { return true; }
        }

        public Type DataType
        {
            get { return field.Type; }
        }

        public object Read(object obj)
        {
            return (obj as IManageProperties).ReadProperty(field);
        }

        public void Write(object obj, object val)
        {
            (obj as IManageProperties).LoadProperty(field, val);
        }
    }
}
